#define BufferSize 256
#define COM7_Data_In_Len 10
#define COM7_Data_Out_Len 12

typedef unsigned int 	UINT_16;
typedef int 	     	SINT_16;
typedef unsigned long 	UINT_32;
typedef long		SINT_32;
typedef unsigned char 	UCHAR;
typedef char 		SCHAR;
typedef float 		FLOAT_32;
typedef double 		FLOAT_64;

class serbuf
{
    private:


    protected:

      UCHAR *InBuf,*OutBuf;
      UINT_16 buf_len;
      volatile UINT_16 pInFront,pInRear,pOutFront,pOutRear;
      volatile UCHAR InOverflow,InUnderflow,OutOverflow,OutUnderflow;
      void WriteOutBuf(UCHAR elem);
      void pt_Out_Align(void);

    public:

      serbuf(UINT_16 buf_size);
      serbuf();
      ~serbuf();
      void ResetInBuf(){pInFront=pInRear=0;}
      void ResetOutBuf(){pOutFront=pOutRear=0;}
      void WriteInBuf(UCHAR elem);
      void pt_In_Align(void);
      UINT_16 ReadInBuf(UCHAR *out_buf);
      UINT_16 ReadOutBuf(UCHAR *out_buf);

};

class COM7_Buf:public serbuf
{
    private:

      UCHAR   *FrameIn,*DataIn,*FrameOut,*DataOut;
      UCHAR    frameOn,RcvOk;
      UINT_16  frameLen,count,frameInLen;

      UINT_16 GetFrame(void);
      UINT_16 Decoding(void);
      UINT_16 Encoding(void);

    public:

      COM7_Buf(UINT_16 buf_size);
      COM7_Buf();
      ~COM7_Buf();
      UINT_16 GetData(UCHAR *in_buf);
      UINT_16 InDataProc(UCHAR *in_buf);
      UINT_16 PutData(UCHAR *out_buf,UINT_16 num);
      UINT_16 PutFrame(void);
      UCHAR   GetRcvFlag(void);

};
